﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SynoManager.DownloadStation.Plugins;
using SynoManager.GUI;

namespace SynoManager.DownloadStation
{
    public partial class DownloadStationPreferencesPanel : PreferencesPanel
    {
        private DownloadStationService service;

        public DownloadStationPreferencesPanel()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DownloadStationPreferencesPanel"/> class.
        /// </summary>
        /// <param name="service">The service.</param>
        public DownloadStationPreferencesPanel(DownloadStationService service)
            :this()
        {
            this.service = service;

            targetFolderComboBox.DataSource = service.Shares.Shares;
            targetFolderComboBox.SelectedItem = service.Shares.SelectedShare;
        }

        /// <summary>
        /// Save/Persist the settings on the <see cref="PreferencesPanel"/>.
        /// </summary>
        public override void Save()
        {
            service.Shares.SelectedShare = (string)targetFolderComboBox.SelectedItem;
            service.Configuration.Save();
            Properties.Settings.Default.Save();
        }
    }
}
